
#ifndef	MEMORY_SLIST_ENTRY_HEAP_H
#define	MEMORY_SLIST_ENTRY_HEAP_H


#include "mutex.h"
#include "aligned_heap.h"
#include "slist.h"


namespace	memory
{
	class	slist_entry_heap
	{
	public:

		slist_entry_heap();
		~slist_entry_heap();

		bool			create();
		void			destroy();

		SLIST_ENTRY*	alloc( size_t size );
		SLIST_ENTRY*	try_alloc( size_t size );
		bool			free( SLIST_ENTRY* p );

		size_t			compact();

	private:

		void			do_delayed_free_list();

	private:

		common::mutex			lock_;
		common::aligned_heap	heap_;
		common::slist			delayed_free_list_;

	};
}




#endif